package com.kws.commercial.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kws.commercial.dao.CommercialProjectScheduleFile;
import com.kws.commercial.dao.Info.QueryProjectFileInfo;
import com.kws.commercial.dao.Rq.UploadProjectScheduleFileRq;
import com.kws.commercial.mapper.CommercialScheduleFileMapper;
import com.kws.commercial.service.CommercialScheduleFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <b>CommercialScheduleFileServiceImpl</b>
 *
 * @description: CommercialScheduleFileServiceImpl <br>
 * @date: 2024/10/29 15:31 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Service
public class CommercialScheduleFileServiceImpl extends ServiceImpl<CommercialScheduleFileMapper, CommercialProjectScheduleFile> implements CommercialScheduleFileService {
    private static final Logger logger = LoggerFactory.getLogger(CommercialScheduleFileServiceImpl.class);

    @Override
    public List<QueryProjectFileInfo> queryProjectScheduleById(Long projectQuotationId) {
        return baseMapper.queryProjectScheduleById(projectQuotationId);
    }

    @Override
    public List<QueryProjectFileInfo> uploadProjectScheduleInfoByProjectQuotationId(UploadProjectScheduleFileRq rq) {
        CommercialProjectScheduleFile commercialProjectScheduleFile = new CommercialProjectScheduleFile();
        commercialProjectScheduleFile.setProjectQuotationId(rq.getProjectQuotationId());
        commercialProjectScheduleFile.setProjectStatus(rq.getProjectStatus());
        commercialProjectScheduleFile.setFileUrl(rq.getFileUrl());
        int insert = baseMapper.insert(commercialProjectScheduleFile);
        if (1 == insert){
            return baseMapper.queryProjectScheduleById(rq.getProjectQuotationId());
        }
        return null;
    }
}
